#!/bin/bash
# sudo apt update
# sudo apt upgrade

# 安装CMake环境
# sudo apt install cmake

# 获取当前目录的绝对路径
CURRENT_DIR="$(pwd)"

# 获取当前目录的名称
CURRENT_NAME="$(basename "$CURRENT_DIR")"

# 目标名称
TARGET_NAME="abdominalmotorServer"

# 如果当前名称不是目标名称
if [ "$CURRENT_NAME" != "$TARGET_NAME" ]; then
  # 获取上一级目录
  PARENT_DIR="$(dirname "$CURRENT_DIR")"

  # 构造目标路径
  TARGET_PATH="$PARENT_DIR/$TARGET_NAME"

  # 重命名当前目录
  mv "$CURRENT_DIR" "$TARGET_PATH"

  echo "目录已重命名为 $TARGET_NAME"
  
  # 切换到新目录（可选）
  cd "$TARGET_PATH"
else
  echo "当前目录已是 $TARGET_NAME"
fi

# 获取当前脚本所在目录的绝对路径
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# lib 文件夹路径
LIB_PATH="$SCRIPT_DIR/lib"

# 设置环境变量
export LD_LIBRARY_PATH="$LIB_PATH:$LD_LIBRARY_PATH"

# 输出测试（可选）
echo "LD_LIBRARY_PATH set to: $LD_LIBRARY_PATH"

# 安装需要的环境
# sudo apt-get install libwebsocketpp-dev
# sudo apt-get install nlohmann-json3-dev
